package com.dragon.modules.yuegou.enums.code;

import com.dragon.common.constant.enums.IBusinessCode;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 会员业务状态码
 * 
 * @author 刘武
 *
 */
public enum HouseCode implements IBusinessCode {


	BUILDING_NOTNULL(23001,"楼栋号不能为空"),
	FLOOR_NOTNULL(23002,"楼层号不能为空"),
	ROOM_NOTNULL(23003,"房间号不能为空"),
	BUSDID_ERROR(23004,"商圈id错误"),
	BUILDING_ERROR(23005,"楼栋号错误"),
	FLOOR_ERROR(23006,"楼层号错误"),
	ROOM_ERROR(23007,"房间号错误"),
	DOOR_NO_ERROR(23008,"户号错误"),
	IMPORT_DOOR_NO_ERROR(23009,"%S户号错误"),
	IMPORT_ROOM_ERROR(23010,"%S房间号与户号不匹配"),
	ROOM_IS_NOT_EXIST(23011,"房间不存在"),

	/**
	 * 状态码说明
	 */
	TODO(23000, "提示消息");
	
	private final Integer code;

	private final String message;

	private HouseCode(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	/**
	 * 把code转化为ResponseCode枚举
	 * 
	 * @param code 代码
	 * @return
	 */
	public static HouseCode from(Integer code) {
		if (code == null) {
			return null;
		}
		return CODE_MAP.get(code);
	}

	/**
	 * Code Map for ResponseCode
	 */
	private static final Map<Integer, HouseCode> CODE_MAP = Stream.of(HouseCode.values())
			.collect(Collectors.toMap(HouseCode::getCode, e -> e));
	
}
